package com.gitee.wsl.model.process

import com.gitee.wsl.eventbus.EventDefinition
import com.gitee.wsl.model.process.request.ProcessRequestBuilder
import com.gitee.wsl.model.process.response.ProcessResponse

/**
 * Occurs after the creation of a new request
 */
 val HttpRequestCreated: EventDefinition<ProcessRequestBuilder> = EventDefinition()

/**
 * Occurs before sending the request, and after execution of all interceptors.
 */
 val HttpRequestIsReadyForSending: EventDefinition<ProcessRequestBuilder> = EventDefinition()

/**
 * Occurs after responses headers have been received.
 */
 val ProcessResponseReceived: EventDefinition<ProcessResponse> = EventDefinition()

/**
 * Utility class containing response and fail reasons for an [ProcessResponseReceiveFailed] event.
 */
 class ProcessResponseReceiveFail(val processResponse: ProcessResponse, val cause: Throwable)

/**
 * Occurs when an exception is thrown during receiving of body.
 */
 val ProcessResponseReceiveFailed: EventDefinition<ProcessResponseReceiveFail> = EventDefinition()

/**
 * Occurs when the response is cancelled due to an exception.
 */
 val ProcessResponseCancelled: EventDefinition<ProcessResponse> = EventDefinition()